/*      */ package dm.jdbc.dataConvertion;
/*      */ 
/*      */ import dm.jdbc.dbaccess.DBError;
/*      */ import dm.jdbc.desc.ParameterDesc;
/*      */ import dm.jdbc.innerData.DmdbParamVal;
/*      */ import dm.sql.ARRAY;
/*      */ import dm.sql.DmdbDateTime;
/*      */ import dm.sql.DmdbIntervalDT;
/*      */ import dm.sql.DmdbIntervalYM;
/*      */ import dm.sql.DmdbTime;
/*      */ import dm.sql.DmdbTimeZone;
/*      */ import dm.sql.STRUCT;
/*      */ import dm.sql.TypeData;
/*      */ import dm.sql.TypeDescriptor;
/*      */ import java.io.IOException;
/*      */ import java.io.InputStream;
/*      */ import java.io.Reader;
/*      */ import java.math.BigDecimal;
/*      */ import java.sql.Blob;
/*      */ import java.sql.Clob;
/*      */ import java.sql.SQLException;
/*      */ import java.sql.Time;
/*      */ import java.sql.Timestamp;
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ public class JType2CType
/*      */ {
/*      */   public static byte[] getBytes(DmdbParamVal paramVal, ParameterDesc desc, CnvtInfo cnvtInfo, int len)
/*      */     throws SQLException
/*      */   {
/*   36 */     byte[] ret = null;
/*      */     
/*   38 */     Object readerOrIn = paramVal.getReaderOrInputStream();
/*   39 */     if (readerOrIn != null) {
/*   40 */       ret = convert_detail(readerOrIn, paramVal, cnvtInfo.getServerEncoding(), len);
/*      */     } else {
/*   42 */       ret = convertWithJType(desc, cnvtInfo, paramVal, len, false);
/*      */     }
/*   44 */     return ret;
/*      */   }
/*      */   
/*      */   public static byte[] getBytes(DmdbParamVal paramVal, ParameterDesc desc, CnvtInfo cnvtInfo)
/*      */     throws SQLException
/*      */   {
/*   50 */     return getBytes(paramVal, desc, cnvtInfo, -1);
/*      */   }
/*      */   
/*      */   private static byte[] convertWithJType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*   56 */     int objType = paramVal.getObjType();
/*   57 */     byte[] retArr = null;
/*   58 */     switch (objType)
/*      */     {
/*      */     case 0: 
/*   61 */       retArr = Boolean2Ctype(paramDesc, cnvtInfo, paramVal, getDtype);
/*   62 */       break;
/*      */     case 1: 
/*   64 */       retArr = Byte2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   65 */       break;
/*      */     case 2: 
/*   67 */       retArr = Short2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   68 */       break;
/*      */     case 3: 
/*   70 */       retArr = Integer2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   71 */       break;
/*      */     case 4: 
/*   73 */       retArr = Long2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   74 */       break;
/*      */     case 5: 
/*   76 */       retArr = Float2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   77 */       break;
/*      */     case 6: 
/*   79 */       retArr = Double2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   80 */       break;
/*      */     case 7: 
/*   82 */       retArr = BigDecimal2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   83 */       break;
/*      */     case 8: 
/*   85 */       retArr = Date2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   86 */       break;
/*      */     case 9: 
/*   88 */       retArr = Time2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   89 */       break;
/*      */     case 10: 
/*   91 */       retArr = TimeStamp2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   92 */       break;
/*      */     case 11: 
/*   94 */       retArr = dmTime2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   95 */       break;
/*      */     case 12: 
/*   97 */       retArr = IntervYM2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*   98 */       break;
/*      */     case 13: 
/*  100 */       retArr = IntervDT2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  101 */       break;
/*      */     case 14: 
/*  103 */       retArr = String2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  104 */       break;
/*      */     case 15: 
/*  106 */       retArr = byteArr2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  107 */       break;
/*      */     case 16: 
/*  109 */       retArr = Blob2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  110 */       break;
/*      */     case 17: 
/*  112 */       retArr = Clob2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  113 */       break;
/*      */     case 18: 
/*  115 */       retArr = Reader2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  116 */       break;
/*      */     case 19: 
/*  118 */       retArr = InputStream2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  119 */       break;
/*      */     case 24: 
/*  121 */       retArr = Null2CType(paramDesc, paramVal, getDtype);
/*  122 */       break;
/*      */     case 25: 
/*  124 */       retArr = Object2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  125 */       break;
/*      */     
/*      */     case 20: 
/*  128 */       retArr = Array2CType(paramDesc, paramVal, getDtype);
/*  129 */       break;
/*      */     
/*      */     case 21: 
/*  132 */       retArr = Struct2CType(paramDesc, paramVal, getDtype);
/*  133 */       break;
/*      */     case 22: case 23: 
/*      */     case 26: 
/*      */     case 27: 
/*      */     default: 
/*  138 */       DBError.throwUnsupportedSQLException();
/*      */     }
/*      */     
/*      */     
/*  142 */     return retArr;
/*      */   }
/*      */   
/*      */   public static void ExactParamType(ParameterDesc paramDesc, DmdbParamVal paramVal) throws SQLException
/*      */   {
/*  147 */     byte typeFlag = paramDesc.getTypeFlag();
/*  148 */     if (typeFlag == 1) {
/*  149 */       return;
/*      */     }
/*  151 */     convertWithJType(paramDesc, null, paramVal, -1, true);
/*      */   }
/*      */   
/*      */   private static byte[] convert_detail(Object readerOrIn, DmdbParamVal paramVal, String serverEncoding, int len)
/*      */     throws SQLException
/*      */   {
/*  157 */     byte[] ret = null;
/*      */     
/*  159 */     if ((readerOrIn instanceof InputStream)) {
/*  160 */       ret = InputStream_bytes((InputStream)readerOrIn, paramVal, len, true);
/*  161 */     } else if ((readerOrIn instanceof Reader)) {
/*  162 */       ret = Reader_chars((Reader)readerOrIn, paramVal, len, serverEncoding, true);
/*      */     } else {
/*  164 */       DBError.throwUnsupportedSQLException();
/*      */     }
/*  166 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Object2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  173 */     Object value = paramVal.getObjVal();
/*      */     
/*  175 */     if (value == null)
/*      */     {
/*  177 */       paramDesc.setParamRecmdInfo(0, 0, 0);
/*  178 */       return null;
/*      */     }
/*      */     
/*  181 */     byte[] ret = null;
/*  182 */     if ((value instanceof Boolean)) {
/*  183 */       ret = Boolean2Ctype(paramDesc, cnvtInfo, paramVal, getDtype);
/*  184 */     } else if ((value instanceof Byte)) {
/*  185 */       ret = Byte2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  186 */     } else if ((value instanceof Short)) {
/*  187 */       ret = Short2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  188 */     } else if ((value instanceof Integer)) {
/*  189 */       ret = Integer2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  190 */     } else if ((value instanceof Long)) {
/*  191 */       ret = Long2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  192 */     } else if ((value instanceof Float)) {
/*  193 */       ret = Float2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  194 */     } else if ((value instanceof Double)) {
/*  195 */       ret = Double2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  196 */     } else if ((value instanceof BigDecimal)) {
/*  197 */       ret = BigDecimal2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  198 */     } else if ((value instanceof java.sql.Date)) {
/*  199 */       ret = Date2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  200 */     } else if ((value instanceof Timestamp)) {
/*  201 */       ret = TimeStamp2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  202 */     } else if ((value instanceof Time)) {
/*  203 */       ret = Time2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  204 */     } else if ((value instanceof DmdbTime)) {
/*  205 */       ret = dmTime2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  206 */     } else if ((value instanceof DmdbIntervalDT)) {
/*  207 */       ret = IntervDT2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  208 */     } else if ((value instanceof DmdbIntervalYM)) {
/*  209 */       ret = IntervYM2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*  210 */     } else if ((value instanceof java.util.Date))
/*      */     {
/*  212 */       java.util.Date udt = (java.util.Date)paramVal.getObjVal();
/*  213 */       java.sql.Date date = new java.sql.Date(udt.getTime());
/*  214 */       paramVal.setInValue(date, 8);
/*  215 */       ret = Date2CType(paramDesc, cnvtInfo, paramVal, getDtype);
/*      */     }
/*  217 */     else if ((value instanceof String)) {
/*  218 */       ret = String2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  219 */     } else if ((value instanceof byte[])) {
/*  220 */       ret = byteArr2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  221 */     } else if ((value instanceof Blob)) {
/*  222 */       ret = Blob2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  223 */     } else if ((value instanceof Clob)) {
/*  224 */       ret = Clob2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  225 */     } else if ((value instanceof Reader)) {
/*  226 */       ret = Reader2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  227 */     } else if ((value instanceof InputStream)) {
/*  228 */       ret = InputStream2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*  229 */     } else if ((value instanceof ARRAY)) {
/*  230 */       ret = Array2CType(paramDesc, paramVal, getDtype);
/*  231 */     } else if ((value instanceof STRUCT)) {
/*  232 */       ret = Struct2CType(paramDesc, paramVal, getDtype);
/*  233 */     } else if ((value instanceof Character)) {
/*  234 */       ret = Char2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*      */     } else {
/*  236 */       DBError.throwUnsupportedSQLException();
/*      */     }
/*  238 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] Char2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  244 */     if (getDtype)
/*      */     {
/*  246 */       paramDesc.setParamRecmdInfo(0, 1, 0);
/*  247 */       return null;
/*      */     }
/*      */     
/*  250 */     char[] chars = new char[1];
/*  251 */     char x = ((Character)paramVal.getObjVal()).charValue();
/*  252 */     chars[0] = x;
/*  253 */     String value = new String(chars);
/*  254 */     paramVal.setInValue(value, 14);
/*  255 */     return String2CType(paramDesc, cnvtInfo, paramVal, len, getDtype);
/*      */   }
/*      */   
/*      */   private static byte[] Array2CType(ParameterDesc paramDesc, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  261 */     Object val = paramVal.getObjVal();
/*  262 */     if (!(val instanceof ARRAY)) {
/*  263 */       DBError.throwSQLException(6007);
/*      */     }
/*  265 */     TypeDescriptor arrDesc = paramDesc.getTypeDescriptor();
/*  266 */     if (getDtype)
/*      */     {
/*  268 */       paramDesc.setParamRecmdInfo(arrDesc.getDType(), 1, 0);
/*  269 */       return null;
/*      */     }
/*      */     
/*  272 */     ARRAY data = (ARRAY)paramVal.getObjVal();
/*  273 */     byte[] tmp = null;
/*  274 */     if (arrDesc.getDType() == 122) {
/*  275 */       tmp = TypeData.sarrayToBytes(data, arrDesc);
/*      */     } else {
/*  277 */       tmp = TypeData.arrayToBytes(data, arrDesc);
/*      */     }
/*  279 */     paramVal.setIsReadOver(true);
/*  280 */     return tmp;
/*      */   }
/*      */   
/*      */   private static byte[] Struct2CType(ParameterDesc paramDesc, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  286 */     Object val = paramVal.getObjVal();
/*  287 */     if (!(val instanceof STRUCT)) {
/*  288 */       DBError.throwSQLException(6007);
/*      */     }
/*  290 */     TypeDescriptor strctDesc = paramDesc.getTypeDescriptor();
/*  291 */     if (getDtype)
/*      */     {
/*  293 */       paramDesc.setParamRecmdInfo(strctDesc.getDType(), 1, 0);
/*  294 */       return null;
/*      */     }
/*      */     
/*  297 */     STRUCT data = (STRUCT)paramVal.getObjVal();
/*  298 */     if (strctDesc.getDType() == 119) {
/*  299 */       return TypeData.objToBytes(data, strctDesc);
/*      */     }
/*  301 */     return TypeData.recordToBytes(data, strctDesc);
/*      */   }
/*      */   
/*      */   private static byte[] Null2CType(ParameterDesc paramDesc, DmdbParamVal paramVal, boolean getDtype)
/*      */   {
/*  306 */     if (getDtype) {
/*  307 */       paramDesc.setParamRecmdInfo(0, 0, 0);
/*      */     }
/*  309 */     return null;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Boolean2Ctype(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  316 */     if (getDtype)
/*      */     {
/*  318 */       paramDesc.setParamRecmdInfo(5, 1, 0);
/*  319 */       return null;
/*      */     }
/*      */     
/*  322 */     boolean x = ((Boolean)paramVal.getObjVal()).booleanValue();
/*  323 */     int value = x ? 1 : 0;
/*  324 */     int typeFlag = paramDesc.getTypeFlag();
/*      */     
/*  326 */     if (typeFlag != 1)
/*      */     {
/*  328 */       paramVal.setIsReadOver(true);
/*  329 */       return Convertion.booleanToByteArray(x);
/*      */     }
/*      */     
/*  332 */     byte[] ret = null;
/*  333 */     int prec = paramDesc.getPrec();
/*  334 */     int dType = paramDesc.getDType();
/*  335 */     int scale = paramDesc.getScale();
/*  336 */     switch (dType)
/*      */     {
/*      */     case 13: 
/*  339 */       ret = Convertion.booleanToByteArray(x);
/*  340 */       break;
/*      */     case 3: 
/*      */     case 5: 
/*  343 */       ret = Convertion.byteToByteArray((byte)value);
/*  344 */       break;
/*      */     case 6: 
/*  346 */       ret = Convertion.shortToByteArray((short)value);
/*  347 */       break;
/*      */     case 7: 
/*  349 */       ret = Convertion.IntToByteArray(value);
/*  350 */       break;
/*      */     case 8: 
/*  352 */       ret = Convertion.longToByteArray(value);
/*  353 */       break;
/*      */     case 10: 
/*  355 */       ret = Convertion.floatToByteArray(value);
/*  356 */       break;
/*      */     case 11: 
/*  358 */       ret = Convertion.doubleToByteArray(value);
/*  359 */       break;
/*      */     case 9: 
/*      */     case 24: 
/*  362 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(value), prec, scale);
/*  363 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  366 */       ret = String_char_2CType(String.valueOf(value), prec, dType, cnvtInfo.getServerEncoding());
/*  367 */       break;
/*      */     case 2: 
/*  369 */       ret = String_varchar_2CType(String.valueOf(value), prec, dType, cnvtInfo.getServerEncoding());
/*  370 */       break;
/*      */     case 19: 
/*  372 */       ret = String_longvar_2CType(String.valueOf(value), cnvtInfo.getServerEncoding(), paramVal, -1);
/*  373 */       break;
/*      */     case 4: case 12: case 14: case 15: case 16: case 17: case 18: case 20: case 21: case 22: case 23: default: 
/*  375 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*  378 */     paramVal.setIsReadOver(true);
/*      */     
/*  380 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Byte2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  387 */     if (getDtype)
/*      */     {
/*  389 */       paramDesc.setParamRecmdInfo(5, 1, 0);
/*  390 */       return null;
/*      */     }
/*      */     
/*  393 */     byte x = ((Byte)paramVal.getObjVal()).byteValue();
/*  394 */     byte typeFlag = paramDesc.getTypeFlag();
/*  395 */     if (typeFlag != 1)
/*      */     {
/*  397 */       paramVal.setIsReadOver(true);
/*  398 */       return Convertion.byteToByteArray(x);
/*      */     }
/*      */     
/*  401 */     byte[] ret = null;
/*  402 */     int prec = paramDesc.getPrec();
/*  403 */     int scale = paramDesc.getScale();
/*  404 */     int dType = paramDesc.getDType();
/*  405 */     switch (dType)
/*      */     {
/*      */     case 3: 
/*  408 */       ret = Convertion.byteToByteArray((byte)(x == 0 ? 0 : 1));
/*  409 */       break;
/*      */     case 5: 
/*  411 */       ret = Convertion.byteToByteArray(x);
/*  412 */       break;
/*      */     case 6: 
/*  414 */       ret = Convertion.shortToByteArray((short)x);
/*  415 */       break;
/*      */     case 7: 
/*  417 */       ret = Convertion.IntToByteArray(x);
/*  418 */       break;
/*      */     case 8: 
/*  420 */       ret = Convertion.longToByteArray(x);
/*  421 */       break;
/*      */     case 10: 
/*  423 */       ret = Convertion.floatToByteArray(x);
/*  424 */       break;
/*      */     case 11: 
/*  426 */       ret = Convertion.doubleToByteArray(x);
/*  427 */       break;
/*      */     case 9: 
/*      */     case 24: 
/*  430 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), prec, scale);
/*  431 */       break;
/*      */     case 13: 
/*  433 */       ret = Convertion.booleanToByteArray(x != 0);
/*  434 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  437 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  438 */       break;
/*      */     case 2: 
/*  440 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  441 */       break;
/*      */     case 19: 
/*  443 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/*  444 */       break;
/*      */     case 4: case 12: case 14: case 15: case 16: case 17: case 18: case 20: case 21: case 22: case 23: default: 
/*  446 */       DBError.throwSQLException(6007);
/*      */     }
/*  448 */     paramVal.setIsReadOver(true);
/*      */     
/*  450 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] Short2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  456 */     if (getDtype)
/*      */     {
/*  458 */       paramDesc.setParamRecmdInfo(6, 2, 0);
/*  459 */       return null;
/*      */     }
/*      */     
/*  462 */     short x = ((Short)paramVal.getObjVal()).shortValue();
/*      */     
/*  464 */     byte typeFlag = paramDesc.getTypeFlag();
/*  465 */     if (typeFlag != 1)
/*      */     {
/*  467 */       paramVal.setIsReadOver(true);
/*  468 */       return Convertion.shortToByteArray(x);
/*      */     }
/*      */     
/*  471 */     byte[] ret = null;
/*  472 */     int prec = paramDesc.getPrec();
/*  473 */     int scale = paramDesc.getScale();
/*  474 */     int dType = paramDesc.getDType();
/*  475 */     switch (dType)
/*      */     {
/*      */     case 6: 
/*  478 */       ret = Convertion.shortToByteArray(x);
/*  479 */       break;
/*      */     case 3: 
/*  481 */       if ((x > 127) || (x < -128)) {
/*  482 */         DBError.throwSQLException(6004);
/*      */       }
/*  484 */       ret = Convertion.byteToByteArray((byte)(x == 0 ? 0 : 1));
/*  485 */       break;
/*      */     case 5: 
/*  487 */       if ((x > 127) || (x < -128)) {
/*  488 */         DBError.throwSQLException(6004);
/*      */       }
/*  490 */       ret = Convertion.byteToByteArray((byte)x);
/*  491 */       break;
/*      */     case 7: 
/*  493 */       ret = Convertion.IntToByteArray(x);
/*  494 */       break;
/*      */     case 8: 
/*  496 */       ret = Convertion.longToByteArray(x);
/*  497 */       break;
/*      */     case 10: 
/*  499 */       ret = Convertion.floatToByteArray(x);
/*  500 */       break;
/*      */     case 11: 
/*  502 */       ret = Convertion.doubleToByteArray(x);
/*  503 */       break;
/*      */     case 9: 
/*      */     case 24: 
/*  506 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), prec, scale);
/*  507 */       break;
/*      */     case 13: 
/*  509 */       ret = Convertion.booleanToByteArray(x != 0);
/*  510 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  513 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  514 */       break;
/*      */     case 2: 
/*  516 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  517 */       break;
/*      */     case 19: 
/*  519 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/*  520 */       break;
/*      */     case 4: case 12: case 14: case 15: case 16: case 17: case 18: case 20: case 21: case 22: case 23: default: 
/*  522 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*  525 */     paramVal.setIsReadOver(true);
/*      */     
/*  527 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] Integer2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  533 */     if (getDtype)
/*      */     {
/*  535 */       paramDesc.setParamRecmdInfo(7, 4, 0);
/*  536 */       return null;
/*      */     }
/*      */     
/*  539 */     int x = ((Integer)paramVal.getObjVal()).intValue();
/*  540 */     byte typeFlag = paramDesc.getTypeFlag();
/*      */     
/*  542 */     if (typeFlag != 1)
/*      */     {
/*  544 */       paramVal.setIsReadOver(true);
/*  545 */       return Convertion.IntToByteArray(x);
/*      */     }
/*      */     
/*  548 */     byte[] ret = null;
/*  549 */     int prec = paramDesc.getPrec();
/*  550 */     int scale = paramDesc.getScale();
/*  551 */     int dType = paramDesc.getDType();
/*  552 */     switch (dType)
/*      */     {
/*      */     case 7: 
/*  555 */       ret = Convertion.IntToByteArray(x);
/*  556 */       break;
/*      */     case 3: 
/*  558 */       if ((x > 127) || (x < -128)) {
/*  559 */         DBError.throwSQLException(6004);
/*      */       }
/*  561 */       ret = Convertion.byteToByteArray((byte)(x == 0 ? 0 : 1));
/*  562 */       break;
/*      */     case 5: 
/*  564 */       if ((x > 127) || (x < -128)) {
/*  565 */         DBError.throwSQLException(6004);
/*      */       }
/*  567 */       ret = Convertion.byteToByteArray((byte)x);
/*  568 */       break;
/*      */     case 6: 
/*  570 */       if ((x > 32767) || (x < 32768)) {
/*  571 */         DBError.throwSQLException(6004);
/*      */       }
/*  573 */       ret = Convertion.shortToByteArray(x);
/*  574 */       break;
/*      */     case 8: 
/*  576 */       ret = Convertion.longToByteArray(x);
/*  577 */       break;
/*      */     case 10: 
/*  579 */       ret = Convertion.floatToByteArray(x);
/*  580 */       break;
/*      */     case 11: 
/*  582 */       ret = Convertion.doubleToByteArray(x);
/*  583 */       break;
/*      */     case 9: 
/*      */     case 24: 
/*  586 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), prec, scale);
/*  587 */       break;
/*      */     case 13: 
/*  589 */       ret = Convertion.booleanToByteArray(x != 0);
/*  590 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  593 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  594 */       break;
/*      */     case 2: 
/*  596 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  597 */       break;
/*      */     case 19: 
/*  599 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/*  600 */       break;
/*      */     case 17: 
/*  602 */       ret = Convertion.intToBinary(x, prec);
/*  603 */       break;
/*      */     case 4: case 12: case 14: case 15: case 16: case 18: case 20: case 21: case 22: case 23: default: 
/*  605 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*  608 */     paramVal.setIsReadOver(true);
/*      */     
/*  610 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] Long2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  616 */     if (getDtype)
/*      */     {
/*  618 */       paramDesc.setParamRecmdInfo(8, 8, 0);
/*  619 */       return null;
/*      */     }
/*      */     
/*  622 */     long x = ((Long)paramVal.getObjVal()).longValue();
/*  623 */     byte typeFlag = paramDesc.getTypeFlag();
/*      */     
/*  625 */     if (typeFlag != 1)
/*      */     {
/*  627 */       paramVal.setIsReadOver(true);
/*  628 */       return Convertion.longToByteArray(x);
/*      */     }
/*      */     
/*  631 */     byte[] ret = null;
/*  632 */     int prec = paramDesc.getPrec();
/*  633 */     int dType = paramDesc.getDType();
/*  634 */     int scale = paramDesc.getScale();
/*  635 */     switch (dType)
/*      */     {
/*      */     case 8: 
/*  638 */       ret = Convertion.longToByteArray(x);
/*      */       
/*  640 */       break;
/*      */     
/*      */     case 3: 
/*  643 */       if ((x > 127L) || (x < -128L)) {
/*  644 */         DBError.throwSQLException(6004);
/*      */       }
/*  646 */       ret = Convertion.byteToByteArray((byte)(x == 0L ? 0 : 1));
/*  647 */       break;
/*      */     
/*      */     case 5: 
/*  650 */       if ((x > 127L) || (x < -128L)) {
/*  651 */         DBError.throwSQLException(6004);
/*      */       }
/*  653 */       ret = Convertion.byteToByteArray((byte)(int)x);
/*  654 */       break;
/*      */     case 6: 
/*  656 */       if ((x > 32767L) || (x < -32768L)) {
/*  657 */         DBError.throwSQLException(6004);
/*      */       }
/*  659 */       ret = Convertion.shortToByteArray((int)x);
/*  660 */       break;
/*      */     case 7: 
/*  662 */       if ((x > 2147483647L) || (x < -2147483648L)) {
/*  663 */         DBError.throwSQLException(6004);
/*      */       }
/*  665 */       ret = Convertion.IntToByteArray((int)x);
/*  666 */       break;
/*      */     case 10: 
/*  668 */       ret = Convertion.floatToByteArray((float)x);
/*  669 */       break;
/*      */     case 11: 
/*  671 */       ret = Convertion.doubleToByteArray(x);
/*  672 */       break;
/*      */     case 9: 
/*      */     case 24: 
/*  675 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), prec, scale);
/*  676 */       break;
/*      */     case 13: 
/*  678 */       ret = Convertion.booleanToByteArray(x != 0L);
/*  679 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  682 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  683 */       break;
/*      */     case 2: 
/*  685 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  686 */       break;
/*      */     case 19: 
/*  688 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/*  689 */       break;
/*      */     case 17: 
/*  691 */       ret = Convertion.longToBinary(x, prec);
/*  692 */       break;
/*      */     case 16: 
/*  694 */       if (x > 2958463L) {
/*  695 */         DBError.throwSQLException(63024);
/*      */       }
/*  697 */       ret = Convertion.getBytes(new java.sql.Date(x * 24L * 60L * 60L * 1000L - 
/*  698 */         2209017600000L).toString(), cnvtInfo.getServerEncoding());
/*  699 */       break;
/*      */     case 15: 
/*  701 */       ret = Convertion.TimeToByteArray(new DmdbTime(String.valueOf(new Time(0L)), scale));
/*  702 */       break;
/*      */     case 14: 
/*  704 */       if (x > 2958463L) {
/*  705 */         DBError.throwSQLException(63024);
/*      */       }
/*  707 */       DmdbDateTime dt = new DmdbDateTime(new java.sql.Date(x * 24L * 60L * 60L * 1000L - 
/*  708 */         2209017600000L).toString(), scale, 0);
/*  709 */       ret = Convertion.DateToByteArray(dt);
/*  710 */       break;
/*      */     case 4: case 12: case 18: case 20: case 21: case 22: case 23: default: 
/*  712 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*  715 */     paramVal.setIsReadOver(true);
/*      */     
/*  717 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Float2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  724 */     if (getDtype)
/*      */     {
/*  726 */       paramDesc.setParamRecmdInfo(10, 0, 0);
/*  727 */       return null;
/*      */     }
/*      */     
/*  730 */     float x = ((Float)paramVal.getObjVal()).floatValue();
/*  731 */     byte typeFlag = paramDesc.getTypeFlag();
/*      */     
/*  733 */     if (typeFlag != 1)
/*      */     {
/*  735 */       paramVal.setIsReadOver(true);
/*  736 */       return Convertion.floatToByteArray(x);
/*      */     }
/*      */     
/*  739 */     byte[] ret = null;
/*  740 */     int prec = paramDesc.getPrec();
/*  741 */     int scale = paramDesc.getScale();
/*  742 */     int dType = paramDesc.getDType();
/*  743 */     switch (dType)
/*      */     {
/*      */     case 10: 
/*  746 */       ret = Convertion.floatToByteArray(x);
/*  747 */       break;
/*      */     
/*      */     case 3: 
/*  750 */       if ((x > 127.0F) || (x < -128.0F)) {
/*  751 */         DBError.throwSQLException(6004);
/*      */       }
/*  753 */       ret = Convertion.byteToByteArray((byte)(x == 0.0F ? 0 : 1));
/*  754 */       break;
/*      */     
/*      */     case 5: 
/*  757 */       ret = Convertion.byteToByteArray((byte)(int)x);
/*  758 */       break;
/*      */     case 6: 
/*  760 */       ret = Convertion.shortToByteArray((short)(int)x);
/*  761 */       break;
/*      */     case 7: 
/*  763 */       ret = Convertion.IntToByteArray((int)x);
/*  764 */       break;
/*      */     case 8: 
/*  766 */       ret = Convertion.longToByteArray(x);
/*  767 */       break;
/*      */     case 11: 
/*  769 */       ret = Convertion.doubleToByteArray(x);
/*  770 */       break;
/*      */     case 9: 
/*      */     case 24: 
/*  773 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), prec, scale);
/*  774 */       break;
/*      */     case 13: 
/*  776 */       ret = Convertion.booleanToByteArray(x != 0.0F);
/*  777 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  780 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  781 */       break;
/*      */     case 2: 
/*  783 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  784 */       break;
/*      */     case 19: 
/*  786 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/*  787 */       break;
/*      */     case 4: case 12: case 14: case 15: case 16: case 17: case 18: case 20: case 21: case 22: case 23: default: 
/*  789 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*  792 */     paramVal.setIsReadOver(true);
/*      */     
/*  794 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Double2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  801 */     if (getDtype)
/*      */     {
/*  803 */       paramDesc.setParamRecmdInfo(11, 0, 0);
/*  804 */       return null;
/*      */     }
/*      */     
/*  807 */     double x = ((Double)paramVal.getObjVal()).doubleValue();
/*  808 */     byte typeFlag = paramDesc.getTypeFlag();
/*      */     
/*  810 */     if (typeFlag != 1)
/*      */     {
/*  812 */       paramVal.setIsReadOver(true);
/*  813 */       return Convertion.doubleToByteArray(x);
/*      */     }
/*      */     
/*  816 */     byte[] ret = null;
/*  817 */     int prec = paramDesc.getPrec();
/*  818 */     int scale = paramDesc.getScale();
/*  819 */     int dType = paramDesc.getDType();
/*  820 */     switch (dType)
/*      */     {
/*      */     case 11: 
/*  823 */       ret = Convertion.doubleToByteArray(x);
/*  824 */       break;
/*      */     
/*      */     case 3: 
/*  827 */       if ((x > 127.0D) || (x < -128.0D)) {
/*  828 */         DBError.throwSQLException(6004);
/*      */       }
/*  830 */       ret = Convertion.byteToByteArray((byte)(x == 0.0D ? 0 : 1));
/*  831 */       break;
/*      */     
/*      */     case 5: 
/*  834 */       ret = Convertion.byteToByteArray((byte)(int)x);
/*  835 */       break;
/*      */     case 6: 
/*  837 */       ret = Convertion.shortToByteArray((short)(int)x);
/*  838 */       break;
/*      */     case 7: 
/*  840 */       ret = Convertion.IntToByteArray((int)x);
/*  841 */       break;
/*      */     case 8: 
/*  843 */       ret = Convertion.longToByteArray(x);
/*  844 */       break;
/*      */     case 10: 
/*  846 */       ret = Convertion.floatToByteArray((float)x);
/*  847 */       break;
/*      */     case 9: 
/*      */     case 24: 
/*  850 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), prec, scale);
/*  851 */       break;
/*      */     case 13: 
/*  853 */       ret = Convertion.booleanToByteArray(x != 0.0D);
/*  854 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  857 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  858 */       break;
/*      */     case 2: 
/*  860 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  861 */       break;
/*      */     case 19: 
/*  863 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/*  864 */       break;
/*      */     case 4: case 12: case 14: case 15: case 16: case 17: case 18: case 20: case 21: case 22: case 23: default: 
/*  866 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*  869 */     paramVal.setIsReadOver(true);
/*      */     
/*  871 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] BigDecimal2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  878 */     int dType = paramDesc.getDType();
/*  879 */     int prec = paramDesc.getPrec();
/*  880 */     int scale = paramDesc.getScale();
/*      */     
/*  882 */     if (getDtype)
/*      */     {
/*  884 */       if ((dType != 11) && (dType != 10)) {
/*  885 */         paramDesc.setParamRecmdInfo(9, 0, 0);
/*      */       } else {
/*  887 */         paramDesc.setParamRecmdInfo(dType, prec, scale);
/*      */       }
/*  889 */       return null;
/*      */     }
/*      */     
/*  892 */     BigDecimal x = (BigDecimal)paramVal.getObjVal();
/*  893 */     byte typeFlag = paramDesc.getTypeFlag();
/*  894 */     if ((typeFlag != 1) && 
/*  895 */       (dType != 11) && (dType != 10))
/*      */     {
/*  897 */       paramVal.setIsReadOver(true);
/*  898 */       return Convertion.BigDecimalToByteArray(String.valueOf(x), 0, 0);
/*      */     }
/*      */     
/*  901 */     byte[] ret = null;
/*  902 */     switch (dType)
/*      */     {
/*      */     case 9: 
/*      */     case 24: 
/*  906 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), prec, scale);
/*  907 */       break;
/*      */     case 3: 
/*  909 */       if ((x.byteValue() > Byte.MAX_VALUE) || (x.byteValue() < Byte.MIN_VALUE)) {
/*  910 */         DBError.throwSQLException(6004);
/*      */       }
/*  912 */       ret = Convertion.byteToByteArray((byte)(x.byteValue() == 0 ? 0 : 1));
/*  913 */       break;
/*      */     case 5: 
/*  915 */       ret = Convertion.byteToByteArray(x.byteValue());
/*  916 */       break;
/*      */     case 6: 
/*  918 */       ret = Convertion.shortToByteArray(x.shortValue());
/*  919 */       break;
/*      */     case 7: 
/*  921 */       ret = Convertion.IntToByteArray(x.intValue());
/*  922 */       break;
/*      */     case 8: 
/*  924 */       ret = Convertion.longToByteArray(x.longValue());
/*  925 */       break;
/*      */     case 10: 
/*  927 */       ret = Convertion.floatToByteArray(x.floatValue());
/*  928 */       break;
/*      */     case 11: 
/*  930 */       ret = Convertion.doubleToByteArray(x.doubleValue());
/*  931 */       break;
/*      */     case 13: 
/*  933 */       boolean b_v = x.equals(new BigDecimal(0.0D));
/*  934 */       ret = Convertion.booleanToByteArray(b_v);
/*  935 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  938 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  939 */       break;
/*      */     case 2: 
/*  941 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  942 */       break;
/*      */     case 19: 
/*  944 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/*  945 */       break;
/*      */     case 4: case 12: case 14: case 15: case 16: case 17: case 18: case 20: case 21: case 22: case 23: default: 
/*  947 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*  950 */     paramVal.setIsReadOver(true);
/*      */     
/*  952 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Date2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/*  959 */     if (getDtype)
/*      */     {
/*  961 */       paramDesc.setParamRecmdInfo(14, 3, 0);
/*  962 */       return null;
/*      */     }
/*      */     
/*  965 */     java.sql.Date x = (java.sql.Date)paramVal.getObjVal();
/*      */     
/*  967 */     int prec = paramDesc.getPrec();
/*  968 */     int dType = paramDesc.getDType();
/*  969 */     int scale = paramDesc.getScale();
/*  970 */     byte typeFlag = paramDesc.getTypeFlag();
/*      */     
/*  972 */     if (typeFlag != 1)
/*      */     {
/*  974 */       DmdbDateTime dt = new DmdbDateTime(x.toString(), scale, 0);
/*  975 */       paramVal.setIsReadOver(true);
/*  976 */       return Convertion.DateToByteArray(dt);
/*      */     }
/*      */     
/*  979 */     byte[] ret = null;
/*  980 */     DmdbDateTime dt = null;
/*  981 */     switch (dType)
/*      */     {
/*      */     case 14: 
/*  984 */       dt = new DmdbDateTime(x.toString(), scale, 0);
/*  985 */       ret = Convertion.DateToByteArray(dt);
/*  986 */       break;
/*      */     case 16: 
/*  988 */       Timestamp ts = new Timestamp(x.getTime());
/*  989 */       dt = new DmdbDateTime(ts.toString(), scale, 2);
/*  990 */       ret = Convertion.TimeStampToByteArray(dt, dType, scale, cnvtInfo.getDbTz(), 
/*  991 */         cnvtInfo.getTimeZone());
/*  992 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*  995 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  996 */       break;
/*      */     case 2: 
/*  998 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/*  999 */       break;
/*      */     case 19: 
/* 1001 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/* 1002 */       break;
/*      */     default: 
/* 1004 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 1007 */     paramVal.setIsReadOver(true);
/*      */     
/* 1009 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] TimeStamp2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1016 */     if (getDtype)
/*      */     {
/* 1018 */       paramDesc.setParamRecmdInfo(16, 8, 0);
/* 1019 */       return null;
/*      */     }
/*      */     
/* 1022 */     Timestamp x = (Timestamp)paramVal.getObjVal();
/* 1023 */     int prec = paramDesc.getPrec();
/* 1024 */     int dType = paramDesc.getDType();
/* 1025 */     int scale = paramDesc.getScale();
/*      */     
/* 1027 */     byte typeFlag = paramDesc.getTypeFlag();
/* 1028 */     if (typeFlag != 1)
/*      */     {
/* 1030 */       DmdbDateTime dt = new DmdbDateTime(x.toString(), scale, 2);
/* 1031 */       paramVal.setIsReadOver(true);
/* 1032 */       return Convertion.TimeStampToByteArray(dt, 16, scale, cnvtInfo.getDbTz(), 
/* 1033 */         cnvtInfo.getTimeZone());
/*      */     }
/*      */     
/* 1036 */     byte[] ret = null;
/* 1037 */     DmdbDateTime dt = null;
/* 1038 */     switch (dType)
/*      */     {
/*      */     case 14: 
/* 1041 */       dt = new DmdbDateTime(new java.sql.Date(x.getTime()).toString(), scale, 0);
/* 1042 */       ret = Convertion.DateToByteArray(dt);
/* 1043 */       break;
/*      */     case 15: 
/* 1045 */       DmdbTime t = new DmdbTime(DmdbDateTime.getTimeFromTimestamp(x), scale);
/* 1046 */       ret = Convertion.TimeToByteArray(t);
/* 1047 */       break;
/*      */     case 16: 
/* 1049 */       dt = new DmdbDateTime(x.toString(), scale, 2);
/* 1050 */       ret = Convertion.TimeStampToByteArray(dt, dType, scale, cnvtInfo.getDbTz(), 
/* 1051 */         cnvtInfo.getTimeZone());
/* 1052 */       break;
/*      */     case 0: 
/*      */     case 1: 
/* 1055 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/* 1056 */       break;
/*      */     case 2: 
/* 1058 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/* 1059 */       break;
/*      */     case 19: 
/* 1061 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/* 1062 */       break;
/*      */     case 20: 
/*      */     case 21: 
/*      */     case 22: 
/*      */     case 23: 
/* 1067 */       dt = new DmdbDateTime(x.toString(), scale, 2);
/* 1068 */       ret = String_javaObj_2CType(dt.getStringFromTimestamp(x), dType, scale, prec, cnvtInfo);
/* 1069 */       break;
/*      */     case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 17: case 18: default: 
/* 1071 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 1074 */     paramVal.setIsReadOver(true);
/*      */     
/* 1076 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Time2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1083 */     if (getDtype)
/*      */     {
/* 1085 */       paramDesc.setParamRecmdInfo(15, 5, 0);
/* 1086 */       return null;
/*      */     }
/*      */     
/* 1089 */     Time x = (Time)paramVal.getObjVal();
/* 1090 */     int prec = paramDesc.getPrec();
/* 1091 */     int dType = paramDesc.getDType();
/* 1092 */     int scale = paramDesc.getScale();
/*      */     
/* 1094 */     byte typeFlag = paramDesc.getTypeFlag();
/* 1095 */     if (typeFlag != 1)
/*      */     {
/* 1097 */       DmdbTime t = new DmdbTime(String.valueOf(x), scale);
/* 1098 */       paramVal.setIsReadOver(true);
/* 1099 */       return Convertion.TimeToByteArray(t);
/*      */     }
/*      */     
/* 1102 */     byte[] ret = null;
/* 1103 */     switch (dType)
/*      */     {
/*      */     case 15: 
/* 1106 */       DmdbTime t = new DmdbTime(String.valueOf(x), scale);
/* 1107 */       ret = Convertion.TimeToByteArray(t);
/* 1108 */       break;
/*      */     case 0: 
/*      */     case 1: 
/* 1111 */       ret = String_char_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/* 1112 */       break;
/*      */     case 2: 
/* 1114 */       ret = String_varchar_2CType(String.valueOf(x), prec, dType, cnvtInfo.getServerEncoding());
/* 1115 */       break;
/*      */     case 19: 
/* 1117 */       ret = String_longvar_2CType(String.valueOf(x), cnvtInfo.getServerEncoding(), paramVal, -1);
/* 1118 */       break;
/*      */     default: 
/* 1120 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 1123 */     paramVal.setIsReadOver(true);
/*      */     
/* 1125 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] dmTime2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1132 */     if (getDtype)
/*      */     {
/* 1134 */       paramDesc.setParamRecmdInfo(15, 5, 0);
/* 1135 */       return null;
/*      */     }
/*      */     
/* 1138 */     DmdbTime t = (DmdbTime)paramVal.getObjVal();
/* 1139 */     int dType = paramDesc.getDType();
/* 1140 */     int scale = paramDesc.getScale();
/*      */     
/* 1142 */     byte typeFlag = paramDesc.getTypeFlag();
/* 1143 */     if (typeFlag != 1)
/*      */     {
/* 1145 */       paramVal.setIsReadOver(true);
/* 1146 */       return Convertion.TimeToByteArray(t);
/*      */     }
/*      */     
/* 1149 */     byte[] ret = null;
/* 1150 */     switch (dType)
/*      */     {
/*      */     case 15: 
/* 1153 */       ret = Convertion.TimeToByteArray(t);
/* 1154 */       break;
/*      */     case 16: 
/* 1156 */       Timestamp ts = new Timestamp(t.getTime().getTime());
/* 1157 */       ts.setNanos(t.getNano());
/* 1158 */       DmdbDateTime dt = new DmdbDateTime(t.toString(), scale, 2);
/* 1159 */       ret = Convertion.TimeStampToByteArray(dt, dType, scale, cnvtInfo.getDbTz(), 
/* 1160 */         cnvtInfo.getTimeZone());
/* 1161 */       break;
/*      */     default: 
/* 1163 */       DmdbParamVal tempVal = paramVal;
/* 1164 */       tempVal.setInValue(String.valueOf(paramVal.getObjVal()), 14);
/* 1165 */       ret = String2CType(paramDesc, cnvtInfo, paramVal, -1, getDtype);
/*      */     }
/*      */     
/*      */     
/* 1169 */     paramVal.setIsReadOver(true);
/*      */     
/* 1171 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] IntervDT2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1177 */     DmdbIntervalDT dt = (DmdbIntervalDT)paramVal.getObjVal();
/* 1178 */     if (getDtype)
/*      */     {
/* 1180 */       if (dt != null) {
/* 1181 */         paramDesc.setParamRecmdInfo(21, 0, dt.getPrecForSvr());
/*      */       }
/* 1183 */       return null;
/*      */     }
/*      */     
/* 1186 */     int dType = paramDesc.getDType();
/* 1187 */     int scale = paramDesc.getScale();
/*      */     
/* 1189 */     byte typeFlag = paramDesc.getTypeFlag();
/* 1190 */     if (typeFlag != 1)
/*      */     {
/* 1192 */       paramVal.setIsReadOver(true);
/* 1193 */       return Convertion.InterDtToByteArray(dt);
/*      */     }
/*      */     
/* 1196 */     byte[] ret = null;
/* 1197 */     switch (dType)
/*      */     {
/*      */     case 21: 
/* 1200 */       ret = Convertion.InterDtToByteArray(dt, scale);
/* 1201 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*      */     case 2: 
/*      */     case 12: 
/*      */     case 17: 
/*      */     case 18: 
/*      */     case 19: 
/* 1209 */       DmdbParamVal tempVal = paramVal;
/* 1210 */       tempVal.setInValue(String.valueOf(paramVal.getObjVal()), 14);
/* 1211 */       String2CType(paramDesc, cnvtInfo, tempVal, -1, getDtype);
/* 1212 */       break;
/*      */     default: 
/* 1214 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*      */     
/* 1218 */     paramVal.setIsReadOver(true);
/*      */     
/* 1220 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] IntervYM2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1226 */     DmdbIntervalYM ym = (DmdbIntervalYM)paramVal.getObjVal();
/*      */     
/* 1228 */     if (getDtype)
/*      */     {
/* 1230 */       if (ym != null)
/* 1231 */         paramDesc.setParamRecmdInfo(20, 0, ym.getPrecForSvr());
/* 1232 */       return null;
/*      */     }
/*      */     
/* 1235 */     int prec = paramDesc.getPrec();
/* 1236 */     int dType = paramDesc.getDType();
/*      */     
/* 1238 */     byte typeFlag = paramDesc.getTypeFlag();
/* 1239 */     if (typeFlag != 1)
/*      */     {
/* 1241 */       paramVal.setIsReadOver(true);
/* 1242 */       return Convertion.InterYMToByteArray(ym);
/*      */     }
/*      */     
/* 1245 */     byte[] ret = null;
/* 1246 */     switch (dType)
/*      */     {
/*      */     case 20: 
/* 1249 */       ret = Convertion.InterYMToByteArray(ym, prec);
/* 1250 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*      */     case 2: 
/*      */     case 12: 
/*      */     case 17: 
/*      */     case 18: 
/*      */     case 19: 
/* 1258 */       DmdbParamVal tempVal = paramVal;
/* 1259 */       tempVal.setInValue(String.valueOf(paramVal.getObjVal()), 14);
/* 1260 */       ret = String2CType(paramDesc, cnvtInfo, tempVal, -1, getDtype);
/* 1261 */       break;
/*      */     default: 
/* 1263 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/*      */     
/* 1267 */     paramVal.setIsReadOver(true);
/*      */     
/* 1269 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] String2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1275 */     if (getDtype)
/*      */     {
/* 1277 */       paramDesc.setParamRecmdInfo(2, 8188, 0);
/* 1278 */       return null;
/*      */     }
/*      */     
/* 1281 */     String x = (String)paramVal.getObjVal();
/* 1282 */     int prec = paramDesc.getPrec();
/* 1283 */     int dType = paramDesc.getDType();
/* 1284 */     int scale = paramDesc.getScale();
/*      */     
/* 1286 */     byte typeFlag = paramDesc.getTypeFlag();
/* 1287 */     if (typeFlag != 1)
/*      */     {
/* 1289 */       byte[] inValueBytes = Convertion.getBytes(x, cnvtInfo.getServerEncoding());
/* 1290 */       paramVal.setIsReadOver(true);
/* 1291 */       return inValueBytes;
/*      */     }
/*      */     
/* 1294 */     byte[] ret = null;
/* 1295 */     switch (dType)
/*      */     {
/*      */     case 0: 
/*      */     case 1: 
/* 1299 */       ret = String_char_2CType(x, prec, dType, cnvtInfo.getServerEncoding());
/* 1300 */       paramVal.setIsReadOver(true);
/* 1301 */       break;
/*      */     case 2: 
/* 1303 */       ret = String_varchar_2CType(x, prec, dType, cnvtInfo.getServerEncoding());
/* 1304 */       paramVal.setIsReadOver(true);
/* 1305 */       break;
/*      */     case 12: 
/*      */     case 17: 
/*      */     case 18: 
/* 1309 */       ret = String_binary_2CType(x, prec, dType);
/* 1310 */       paramVal.setIsReadOver(true);
/* 1311 */       break;
/*      */     case 19: 
/* 1313 */       ret = String_longvar_2CType(x, cnvtInfo.getServerEncoding(), paramVal, len);
/* 1314 */       break;
/*      */     case 3: 
/* 1316 */       byte val = 1;
/* 1317 */       if (x.length() > 0)
/*      */       {
/* 1319 */         if ((x.charAt(0) == '0') || ("false".equalsIgnoreCase(x))) {
/* 1320 */           val = 0;
/*      */         }
/* 1322 */         ret = Convertion.byteToByteArray(val);
/*      */       }
/*      */       else
/*      */       {
/* 1326 */         paramVal.setIsNull(true);
/*      */       }
/* 1328 */       paramVal.setIsReadOver(true);
/* 1329 */       break;
/*      */     case 5: 
/* 1331 */       if (x.trim().length() > 0) {
/* 1332 */         ret = Convertion.byteToByteArray(Byte.parseByte(x.trim()));
/*      */       } else {
/* 1334 */         paramVal.setIsNull(true);
/*      */       }
/* 1336 */       paramVal.setIsReadOver(true);
/* 1337 */       break;
/*      */     case 6: 
/* 1339 */       if (x.trim().length() > 0) {
/* 1340 */         ret = Convertion.shortToByteArray(Short.parseShort(x.trim()));
/*      */       } else
/* 1342 */         paramVal.setIsNull(true);
/* 1343 */       paramVal.setIsReadOver(true);
/* 1344 */       break;
/*      */     case 7: 
/* 1346 */       if (x.trim().length() > 0) {
/* 1347 */         ret = Convertion.IntToByteArray(Integer.parseInt(x.trim()));
/*      */       } else
/* 1349 */         paramVal.setIsNull(true);
/* 1350 */       paramVal.setIsReadOver(true);
/* 1351 */       break;
/*      */     case 8: 
/* 1353 */       if (x.trim().length() > 0) {
/* 1354 */         ret = Convertion.longToByteArray(Long.parseLong(x.trim()));
/*      */       } else
/* 1356 */         paramVal.setIsNull(true);
/* 1357 */       paramVal.setIsReadOver(true);
/* 1358 */       break;
/*      */     case 10: 
/* 1360 */       if (x.trim().length() > 0) {
/* 1361 */         ret = Convertion.floatToByteArray(Float.parseFloat(x.trim()));
/*      */       } else
/* 1363 */         paramVal.setIsNull(true);
/* 1364 */       paramVal.setIsReadOver(true);
/* 1365 */       break;
/*      */     case 11: 
/* 1367 */       if (x.trim().length() > 0) {
/* 1368 */         ret = Convertion.doubleToByteArray(Double.parseDouble(x.trim()));
/*      */       } else
/* 1370 */         paramVal.setIsNull(true);
/* 1371 */       paramVal.setIsReadOver(true);
/* 1372 */       break;
/*      */     case 9: 
/*      */     case 24: 
/* 1375 */       if (x.trim().length() > 0) {
/* 1376 */         ret = Convertion.BigDecimalToByteArray(x, prec, scale);
/*      */       } else
/* 1378 */         paramVal.setIsNull(true);
/* 1379 */       paramVal.setIsReadOver(true);
/* 1380 */       break;
/*      */     case 13: 
/* 1382 */       if (x.trim().length() > 0)
/*      */       {
/* 1384 */         boolean b = false;
/* 1385 */         if ((!x.trim().equalsIgnoreCase("0")) || (Boolean.valueOf(x).booleanValue()))
/* 1386 */           b = true;
/* 1387 */         ret = Convertion.booleanToByteArray(b);
/*      */       }
/*      */       else {
/* 1390 */         paramVal.setIsNull(true); }
/* 1391 */       paramVal.setIsReadOver(true);
/* 1392 */       break;
/*      */     case 14: 
/* 1394 */       if (x.trim().length() > 0)
/*      */       {
/* 1396 */         DmdbDateTime dt = new DmdbDateTime(x.trim(), scale, 0);
/* 1397 */         ret = Convertion.DateToByteArray(dt);
/*      */       }
/*      */       else {
/* 1400 */         paramVal.setIsNull(true); }
/* 1401 */       paramVal.setIsReadOver(true);
/* 1402 */       break;
/*      */     case 15: 
/* 1404 */       if (x.trim().length() > 0)
/*      */       {
/* 1406 */         DmdbTime t = new DmdbTime(x.trim(), scale);
/* 1407 */         ret = Convertion.TimeToByteArray(t);
/*      */       }
/*      */       else {
/* 1410 */         paramVal.setIsNull(true); }
/* 1411 */       paramVal.setIsReadOver(true);
/* 1412 */       break;
/*      */     case 16: 
/* 1414 */       if (x.trim().length() > 0)
/*      */       {
/* 1416 */         Timestamp ts = DmdbDateTime.getTimestampByString(x.trim(), dType, scale, 
/* 1417 */           cnvtInfo.getTimeZone());
/* 1418 */         DmdbDateTime dt = new DmdbDateTime(ts.toString(), scale, 2);
/* 1419 */         ret = Convertion.TimeStampToByteArray(dt, dType, scale, cnvtInfo.getDbTz(), 
/* 1420 */           cnvtInfo.getTimeZone());
/*      */       }
/*      */       else {
/* 1423 */         paramVal.setIsNull(true); }
/* 1424 */       paramVal.setIsReadOver(true);
/* 1425 */       break;
/*      */     case 20: 
/*      */     case 21: 
/*      */     case 22: 
/*      */     case 23: 
/* 1430 */       if (x.trim().length() > 0) {
/* 1431 */         ret = String_javaObj_2CType(x, dType, scale, prec, cnvtInfo);
/*      */       } else {
/* 1433 */         paramVal.setIsNull(true);
/*      */       }
/* 1435 */       paramVal.setIsReadOver(true);
/* 1436 */       break;
/*      */     case 4: default: 
/* 1438 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 1441 */     return ret;
/*      */   }
/*      */   
/*      */   public static byte[] String_char_2CType(String str, int prec, int cType, String serverEncoding)
/*      */     throws SQLException
/*      */   {
/* 1447 */     if (str == null) {
/* 1448 */       return null;
/*      */     }
/* 1450 */     byte[] bs = Convertion.getBytes(str, serverEncoding);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1469 */     return bs;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */   public static byte[] String_varchar_2CType(String str, int prec, int dType, String serverEncoding)
/*      */     throws SQLException
/*      */   {
/* 1477 */     byte[] inValueBytes = Convertion.getBytes(str, serverEncoding);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1485 */     return inValueBytes;
/*      */   }
/*      */   
/*      */   private static byte[] String_longvar_2CType(String str, String serverEncoding, DmdbParamVal paramVal, int length)
/*      */     throws SQLException
/*      */   {
/* 1491 */     int len = str.length();
/* 1492 */     int offset = paramVal.getOffset();
/*      */     
/* 1494 */     int readLen = 0;
/* 1495 */     if (length <= 0) {
/* 1496 */       length = 8000;
/*      */     }
/* 1498 */     if (len - offset > length)
/*      */     {
/* 1500 */       readLen = length;
/* 1501 */       paramVal.setIsReadOver(false);
/*      */     }
/*      */     else {
/* 1504 */       readLen = len - offset;
/*      */     }
/* 1506 */     String subStr = str.substring(offset, offset + readLen);
/* 1507 */     offset += subStr.length();
/*      */     
/* 1509 */     paramVal.setOffset(offset);
/* 1510 */     if (offset >= len) {
/* 1511 */       paramVal.setIsReadOver(true);
/*      */     }
/* 1513 */     return Convertion.getBytes(subStr, serverEncoding);
/*      */   }
/*      */   
/*      */   public static byte[] String_binary_2CType(String str, int prec, int dType)
/*      */     throws SQLException
/*      */   {
/* 1519 */     if (dType == 17) {
/* 1520 */       return Convertion.stringToBinary(str, prec);
/*      */     }
/* 1522 */     return Convertion.stringToBinary(str, prec);
/*      */   }
/*      */   
/*      */   private static byte[] String_javaObj_2CType(String x, int dType, int scale, int prec, CnvtInfo cnvtInfo)
/*      */     throws SQLException
/*      */   {
/* 1528 */     byte[] ret = null;
/* 1529 */     x = x.trim();
/* 1530 */     if (x.length() > 0)
/*      */     {
/* 1532 */       int secPrec = scale & 0xF;
/* 1533 */       int loadPrec = scale >> 4 & 0xF;
/* 1534 */       switch (dType)
/*      */       {
/*      */       case 21: 
/* 1537 */         DmdbIntervalDT dt = new DmdbIntervalDT(x, loadPrec, secPrec);
/* 1538 */         ret = Convertion.InterDtToByteArray(dt, scale);
/* 1539 */         break;
/*      */       case 20: 
/* 1541 */         DmdbIntervalYM ym = new DmdbIntervalYM(x, loadPrec);
/* 1542 */         ret = Convertion.InterYMToByteArray(ym, scale);
/* 1543 */         break;
/*      */       
/*      */ 
/*      */       case 22: 
/*      */       case 23: 
/* 1548 */         DmdbTimeZone tz = null;
/* 1549 */         if (dType == 22)
/*      */         {
/* 1551 */           tz = new DmdbTimeZone(x, 1, cnvtInfo.getTimeZone());
/* 1552 */           ret = Convertion.TimeZoneToByteArray(tz);
/*      */         }
/*      */         else
/*      */         {
/* 1556 */           tz = new DmdbTimeZone(x, 2, cnvtInfo.getTimeZone());
/* 1557 */           ret = Convertion.DateTimeZoneToByteArray(tz);
/*      */         }
/* 1559 */         break;
/*      */       
/*      */       default: 
/* 1562 */         DBError.throwSQLException(6014);
/*      */         
/* 1564 */         break; }
/*      */     } else {
/* 1566 */       ret = null;
/*      */     }
/* 1568 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] byteArr2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1575 */     if (getDtype)
/*      */     {
/* 1577 */       paramDesc.setParamRecmdInfo(18, 8188, 0);
/* 1578 */       return null;
/*      */     }
/*      */     
/* 1581 */     byte[] x = (byte[])paramVal.getObjVal();
/* 1582 */     if ((paramVal.getOutDataBound()) && (paramDesc.getIOType() != 0)) {
/* 1583 */       return x;
/*      */     }
/* 1585 */     int prec = paramDesc.getPrec();
/* 1586 */     int dType = paramDesc.getDType();
/* 1587 */     byte typeFlag = paramDesc.getTypeFlag();
/*      */     
/* 1589 */     if (typeFlag != 1)
/*      */     {
/* 1591 */       paramVal.setIsReadOver(true);
/* 1592 */       return x;
/*      */     }
/*      */     
/* 1595 */     byte[] bs = null;
/* 1596 */     switch (dType)
/*      */     {
/*      */ 
/*      */     case 17: 
/* 1600 */       bs = x;
/* 1601 */       paramVal.setIsReadOver(true);
/* 1602 */       break;
/*      */     
/*      */     case 18: 
/* 1605 */       bs = x;
/* 1606 */       paramVal.setIsReadOver(true);
/* 1607 */       break;
/*      */     case 12: 
/*      */     case 19: 
/* 1610 */       bs = byteArr_longvar_2CType(x, dType, paramVal, len);
/* 1611 */       break;
/*      */     case 0: 
/*      */     case 1: 
/*      */     case 2: 
/* 1615 */       bs = byteArr_char_2CType(x, prec, dType);
/* 1616 */       paramVal.setIsReadOver(true);
/* 1617 */       break;
/*      */     default: 
/* 1619 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 1622 */     return bs;
/*      */   }
/*      */   
/*      */   private static byte[] byteArr_char_2CType(byte[] bs, int prec, int cType) throws SQLException
/*      */   {
/* 1627 */     return Convertion.binaryArrToString(bs, prec, cType);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private static byte[] byteArr_longvar_2CType(byte[] bs, int dType, DmdbParamVal paramVal, int length)
/*      */     throws SQLException
/*      */   {
/* 1664 */     int offset = paramVal.getOffset();
/*      */     
/* 1666 */     int len = bs.length;
/* 1667 */     if (length <= 0) {
/* 1668 */       length = 16000;
/*      */     }
/* 1670 */     int readLen = 0;
/* 1671 */     if (len - offset > length)
/*      */     {
/* 1673 */       readLen = length;
/* 1674 */       paramVal.setIsReadOver(false);
/*      */     }
/*      */     else {
/* 1677 */       readLen = len - offset;
/*      */     }
/* 1679 */     byte[] ret = new byte[readLen];
/* 1680 */     System.arraycopy(bs, offset, ret, 0, readLen);
/* 1681 */     offset += ret.length;
/*      */     
/* 1683 */     paramVal.setOffset(offset);
/* 1684 */     if (offset >= len) {
/* 1685 */       paramVal.setIsReadOver(true);
/*      */     }
/* 1687 */     if (dType == 12) {
/* 1688 */       return ret;
/*      */     }
/* 1690 */     return Convertion.binaryArrToString(ret, readLen * 2, dType);
/*      */   }
/*      */   
/*      */   private static byte[] Blob_getBytes(Blob lob, DmdbParamVal paramVal, int length) throws SQLException
/*      */   {
/* 1695 */     long len = lob.length();
/* 1696 */     int offSet = paramVal.getOffset();
/* 1697 */     if (length <= 0) {
/* 1698 */       length = 32000;
/*      */     }
/* 1700 */     int readLen = 0;
/* 1701 */     if (len - offSet > length)
/*      */     {
/* 1703 */       readLen = length;
/* 1704 */       paramVal.setIsReadOver(false);
/*      */     }
/*      */     else {
/* 1707 */       readLen = (int)(len - offSet);
/*      */     }
/* 1709 */     byte[] ret = lob.getBytes(offSet + 1, readLen);
/* 1710 */     if (ret != null) {
/* 1711 */       offSet += ret.length;
/*      */     }
/* 1713 */     paramVal.setOffset(offSet);
/*      */     
/* 1715 */     if (offSet >= len) {
/* 1716 */       paramVal.setIsReadOver(true);
/*      */     }
/* 1718 */     return ret;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Blob2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1725 */     int prec = paramDesc.getPrec();
/*      */     
/* 1727 */     if (getDtype)
/*      */     {
/* 1729 */       paramDesc.setParamRecmdInfo(12, prec, 0);
/* 1730 */       return null;
/*      */     }
/*      */     
/* 1733 */     Blob lob = (Blob)paramVal.getObjVal();
/* 1734 */     int dType = paramDesc.getDType();
/* 1735 */     byte typeFlag = paramDesc.getTypeFlag();
/*      */     
/* 1737 */     if (typeFlag != 1) {
/* 1738 */       return Blob_getBytes(lob, paramVal, len);
/*      */     }
/* 1740 */     byte[] ret = null;
/* 1741 */     switch (dType)
/*      */     {
/*      */     case 12: 
/* 1744 */       ret = Blob_getBytes(lob, paramVal, len);
/* 1745 */       break;
/*      */     
/*      */     case 117: 
/*      */     case 119: 
/*      */     case 121: 
/*      */     case 122: 
/* 1751 */       TypeDescriptor typeDesc = paramDesc.getTypeDescriptor();
/* 1752 */       if (typeDesc != null) {
/* 1753 */         ret = Blob_obj_getBytes(lob, typeDesc);
/*      */       } else
/* 1755 */         DBError.throwSQLException(6007);
/* 1756 */       break;
/*      */     
/*      */     default: 
/* 1759 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 1762 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] Blob_obj_getBytes(Blob blob, TypeDescriptor desc) throws SQLException
/*      */   {
/* 1767 */     long len = blob.length();
/* 1768 */     byte[] buf = blob.getBytes(1L, (int)len);
/* 1769 */     return TypeData.objBlobToBytes(buf, desc);
/*      */   }
/*      */   
/*      */   private static byte[] Clob_getBytes(Clob lob, DmdbParamVal paramVal, int length, String serverEncoding)
/*      */     throws SQLException
/*      */   {
/* 1775 */     long len = lob.length();
/* 1776 */     int offset = paramVal.getOffset();
/*      */     
/* 1778 */     if (length <= 0) {
/* 1779 */       length = 8000;
/*      */     }
/* 1781 */     int readLen = 0;
/*      */     
/* 1783 */     if (len - offset > length) {
/* 1784 */       readLen = length;
/*      */     } else {
/* 1786 */       readLen = (int)(len - offset);
/*      */     }
/* 1788 */     String subStr = lob.getSubString(offset + 1, readLen);
/* 1789 */     if (subStr != null) {
/* 1790 */       offset += subStr.length();
/*      */     }
/* 1792 */     paramVal.setOffset(offset);
/*      */     
/* 1794 */     if (offset >= len) {
/* 1795 */       paramVal.setIsReadOver(true);
/*      */     }
/* 1797 */     return Convertion.getBytes(subStr, serverEncoding);
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Clob2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1804 */     int prec = paramDesc.getPrec();
/* 1805 */     if (getDtype)
/*      */     {
/* 1807 */       paramDesc.setParamRecmdInfo(19, prec, 0);
/* 1808 */       return null;
/*      */     }
/*      */     
/* 1811 */     int dType = paramDesc.getDType();
/* 1812 */     Clob lob = (Clob)paramVal.getObjVal();
/*      */     
/* 1814 */     byte typeFlag = paramDesc.getTypeFlag();
/* 1815 */     if (typeFlag != 1) {
/* 1816 */       return Clob_getBytes(lob, paramVal, len, cnvtInfo.getServerEncoding());
/*      */     }
/* 1818 */     byte[] ret = null;
/* 1819 */     switch (dType)
/*      */     {
/*      */     case 2: 
/*      */     case 19: 
/* 1823 */       ret = Clob_getBytes(lob, paramVal, len, cnvtInfo.getServerEncoding());
/* 1824 */       break;
/*      */     default: 
/* 1826 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 1829 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] InputStream_bytes_exec(InputStream in, int readLen) throws IOException
/*      */   {
/* 1834 */     byte[] bs = new byte[readLen];
/* 1835 */     int len = in.read(bs, 0, bs.length);
/* 1836 */     if (len <= 0) {
/* 1837 */       return null;
/*      */     }
/* 1839 */     byte[] ret = new byte[len];
/* 1840 */     System.arraycopy(bs, 0, ret, 0, ret.length);
/* 1841 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] InputStream_bytes(InputStream in, DmdbParamVal paramVal, int length, boolean isLob)
/*      */     throws SQLException
/*      */   {
/*      */     try
/*      */     {
/* 1849 */       boolean isNeedReadComplete = false;
/*      */       
/* 1851 */       int readLen = 0;
/* 1852 */       if (length <= 0)
/*      */       {
/* 1854 */         readLen = 32000;
/* 1855 */         isNeedReadComplete = true;
/*      */       }
/*      */       else
/*      */       {
/* 1859 */         readLen = length;
/*      */         
/* 1861 */         if ((!paramVal.streamConverted()) && (paramVal.hasLength()) && 
/* 1862 */           (readLen > paramVal.leftWithLength())) {
/* 1863 */           readLen = (int)paramVal.leftWithLength();
/*      */         }
/*      */       }
/* 1866 */       int retLen = 32000;
/* 1867 */       byte[] ret = new byte[retLen];
/* 1868 */       int retHasLen = 0;
/*      */       
/* 1870 */       byte[] retTemp = null;
/* 1871 */       while (!paramVal.getIsReadOver())
/*      */       {
/* 1873 */         if ((!isLob) && (retHasLen > 8188))
/*      */         {
/* 1875 */           DBError.throwSQLException(6067);
/*      */         }
/*      */         else
/*      */         {
/* 1879 */           byte[] retOnce = InputStream_bytes_exec(in, readLen);
/* 1880 */           if (retOnce == null)
/*      */           {
/* 1882 */             paramVal.setIsReadOver(true);
/*      */ 
/*      */           }
/*      */           else
/*      */           {
/* 1887 */             if (retHasLen + retOnce.length > retLen)
/*      */             {
/* 1889 */               retTemp = new byte[retHasLen];
/* 1890 */               System.arraycopy(ret, 0, retTemp, 0, retHasLen);
/*      */               
/*      */ 
/* 1893 */               ret = new byte[retHasLen + retLen];
/* 1894 */               System.arraycopy(retTemp, 0, ret, 0, retHasLen);
/*      */               
/* 1896 */               retTemp = null;
/*      */             }
/*      */             
/* 1899 */             System.arraycopy(retOnce, 0, ret, retHasLen, retOnce.length);
/* 1900 */             retHasLen += retOnce.length;
/* 1901 */             retOnce = null;
/*      */             
/*      */ 
/* 1904 */             if (!isNeedReadComplete)
/*      */               break;
/*      */           }
/*      */         } }
/* 1908 */       retTemp = new byte[retHasLen];
/* 1909 */       System.arraycopy(ret, 0, retTemp, 0, retHasLen);
/*      */       
/* 1911 */       if ((!paramVal.streamConverted()) && (paramVal.hasLength()))
/* 1912 */         paramVal.calcReadLen(retHasLen);
/* 1913 */       return retTemp;
/*      */     }
/*      */     catch (IOException e)
/*      */     {
/* 1917 */       DBError.throwSQLException(e.toString(), -1);
/*      */     }
/*      */     
/* 1920 */     return null;
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private static void setRecmdTypeForInputStream(ParameterDesc paramDesc)
/*      */     throws SQLException
/*      */   {
/* 1939 */     int dtype = paramDesc.getDType();
/* 1940 */     switch (dtype)
/*      */     {
/*      */     case 0: 
/*      */     case 1: 
/*      */     case 2: 
/*      */     case 17: 
/*      */     case 18: 
/* 1947 */       paramDesc.setParamRecmdInfo(18, 8188, 0);
/* 1948 */       break;
/*      */     
/*      */     case 12: 
/*      */     case 19: 
/* 1952 */       paramDesc.setParamRecmdInfo(12, Integer.MAX_VALUE, 0);
/* 1953 */       break;
/*      */     
/*      */     default: 
/* 1956 */       DBError.throwSQLException(6007);
/*      */     }
/*      */   }
/*      */   
/*      */   private static byte[] InputStream2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 1963 */     if (getDtype)
/*      */     {
/* 1965 */       setRecmdTypeForInputStream(paramDesc);
/* 1966 */       return null;
/*      */     }
/*      */     
/* 1969 */     boolean isLob = checkLobForStream(paramDesc);
/*      */     
/* 1971 */     InputStream in = (InputStream)paramVal.getObjVal();
/* 1972 */     int dType = paramDesc.getDType();
/* 1973 */     byte typeFlag = paramDesc.getTypeFlag();
/*      */     
/* 1975 */     if (typeFlag != 1) {
/* 1976 */       return InputStream_bytes(in, paramVal, len, isLob);
/*      */     }
/* 1978 */     byte[] ret = null;
/* 1979 */     switch (dType)
/*      */     {
/*      */ 
/*      */ 
/*      */ 
/*      */     case 0: 
/*      */     case 1: 
/*      */     case 2: 
/*      */     case 12: 
/*      */     case 17: 
/*      */     case 18: 
/*      */     case 19: 
/*      */     case 119: 
/* 1992 */       TypeDescriptor clsDesc = paramDesc.getTypeDescriptor();
/* 1993 */       if ((dType == 119) && (clsDesc != null)) {
/* 1994 */         isLob = true;
/*      */       }
/* 1996 */       ret = InputStream_bytes(in, paramVal, len, isLob);
/*      */       
/* 1998 */       if ((dType == 119) && (clsDesc != null))
/* 1999 */         ret = TypeData.objBlobToBytes(ret, clsDesc);
/* 2000 */       break;
/*      */     default: 
/* 2002 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 2005 */     return ret;
/*      */   }
/*      */   
/*      */   private static byte[] Reader_bytes(Reader reader, DmdbParamVal paramVal, int length, String serverEncoding, boolean isLob)
/*      */     throws SQLException
/*      */   {
/* 2011 */     ReaderToInputStream chgTemp = new ReaderToInputStream();
/* 2012 */     InputStream in = null;
/* 2013 */     if (paramVal.hasLength()) {
/* 2014 */       in = chgTemp.ReaderTo(reader, serverEncoding, paramVal.getLength());
/*      */     } else
/* 2016 */       in = chgTemp.ReaderTo(reader, serverEncoding);
/* 2017 */     paramVal.setReaderOrInputStream(in);
/*      */     
/* 2019 */     return InputStream_bytes(in, paramVal, length, isLob);
/*      */   }
/*      */   
/*      */   private static String Reader_chars_exec(Reader reader, int readLen) throws IOException
/*      */   {
/* 2024 */     char[] chars = new char[readLen];
/* 2025 */     int len = reader.read(chars, 0, chars.length);
/* 2026 */     if (len <= 0) {
/* 2027 */       return null;
/*      */     }
/* 2029 */     String strRet = new String(chars, 0, len);
/* 2030 */     return strRet;
/*      */   }
/*      */   
/*      */   private static byte[] Reader_chars(Reader reader, DmdbParamVal paramVal, int length, String serverEncoding, boolean isLob)
/*      */     throws SQLException
/*      */   {
/*      */     try
/*      */     {
/* 2038 */       boolean isNeedReadComplete = false;
/* 2039 */       int readLen = 0;
/* 2040 */       if (length <= 0)
/*      */       {
/* 2042 */         readLen = 8000;
/* 2043 */         isNeedReadComplete = true;
/*      */       }
/*      */       else
/*      */       {
/* 2047 */         readLen = length;
/*      */         
/* 2049 */         if ((!paramVal.streamConverted()) && (paramVal.hasLength()) && 
/* 2050 */           (readLen > paramVal.leftWithLength())) {
/* 2051 */           readLen = (int)paramVal.leftWithLength();
/*      */         }
/*      */       }
/* 2054 */       StringBuffer strBuf = new StringBuffer();
/* 2055 */       String strTemp = null;
/* 2056 */       int hasReadLen = 0;
/* 2057 */       while (!paramVal.getIsReadOver())
/*      */       {
/* 2059 */         if ((!isLob) && (hasReadLen > 8188))
/*      */         {
/* 2061 */           DBError.throwSQLException(6067);
/*      */         }
/*      */         else
/*      */         {
/* 2065 */           strTemp = Reader_chars_exec(reader, readLen);
/* 2066 */           if (strTemp == null)
/*      */           {
/* 2068 */             paramVal.setIsReadOver(true);
/*      */           }
/*      */           else
/*      */           {
/* 2072 */             strBuf.append(strTemp);
/* 2073 */             hasReadLen += strTemp.length();
/* 2074 */             if ((!paramVal.streamConverted()) && (paramVal.hasLength())) {
/* 2075 */               paramVal.calcReadLen(strTemp.length());
/*      */             }
/* 2077 */             if (!isNeedReadComplete)
/*      */               break;
/*      */           }
/*      */         } }
/* 2081 */       return Convertion.getBytes(strBuf.toString(), serverEncoding);
/*      */     }
/*      */     catch (IOException e)
/*      */     {
/* 2085 */       DBError.throwSQLException(e.toString(), -1);
/*      */     }
/*      */     
/* 2088 */     return null;
/*      */   }
/*      */   
/*      */   private static void setRecmdTypeForReader(ParameterDesc paramDesc) throws SQLException
/*      */   {
/* 2093 */     int dtype = paramDesc.getDType();
/* 2094 */     switch (dtype)
/*      */     {
/*      */     case 0: 
/*      */     case 1: 
/*      */     case 2: 
/*      */     case 17: 
/*      */     case 18: 
/* 2101 */       paramDesc.setParamRecmdInfo(2, 8188, 0);
/* 2102 */       break;
/*      */     
/*      */     case 12: 
/*      */     case 19: 
/* 2106 */       paramDesc.setParamRecmdInfo(19, Integer.MAX_VALUE, 0);
/* 2107 */       break;
/*      */     
/*      */     default: 
/* 2110 */       DBError.throwSQLException(6007);
/*      */     }
/*      */   }
/*      */   
/*      */   private static boolean checkLobForStream(ParameterDesc paramDesc)
/*      */   {
/* 2116 */     byte typeFlag = paramDesc.getTypeFlag();
/* 2117 */     int dtype = typeFlag == 1 ? paramDesc.getDType() : paramDesc
/* 2118 */       .getRecommendDType();
/*      */     
/* 2120 */     if ((dtype == 12) || (dtype == 19)) {
/* 2121 */       return true;
/*      */     }
/* 2123 */     return false;
/*      */   }
/*      */   
/*      */ 
/*      */   private static byte[] Reader2CType(ParameterDesc paramDesc, CnvtInfo cnvtInfo, DmdbParamVal paramVal, int len, boolean getDtype)
/*      */     throws SQLException
/*      */   {
/* 2130 */     if (getDtype)
/*      */     {
/* 2132 */       setRecmdTypeForReader(paramDesc);
/* 2133 */       return null;
/*      */     }
/*      */     
/* 2136 */     Reader reader = (Reader)paramVal.getObjVal();
/* 2137 */     int dType = paramDesc.getDType();
/*      */     
/* 2139 */     boolean isLob = checkLobForStream(paramDesc);
/*      */     
/* 2141 */     byte typeFlag = paramDesc.getTypeFlag();
/* 2142 */     if (typeFlag != 1) {
/* 2143 */       return Reader_chars(reader, paramVal, len, cnvtInfo.getServerEncoding(), isLob);
/*      */     }
/* 2145 */     byte[] ret = null;
/* 2146 */     switch (dType)
/*      */     {
/*      */     case 0: 
/*      */     case 1: 
/*      */     case 2: 
/*      */     case 19: 
/* 2152 */       ret = Reader_chars(reader, paramVal, len, cnvtInfo.getServerEncoding(), isLob);
/* 2153 */       break;
/*      */     case 12: 
/*      */     case 17: 
/*      */     case 18: 
/* 2157 */       ret = Reader_bytes(reader, paramVal, len, cnvtInfo.getServerEncoding(), isLob);
/* 2158 */       break;
/*      */     default: 
/* 2160 */       DBError.throwSQLException(6007);
/*      */     }
/*      */     
/* 2163 */     return ret;
/*      */   }
/*      */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\dataConvertion\JType2CType.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */